// File LocationMachine.h
//
// Purpose: Contains the machine for monitoring locations
//
// Author : Bryson King (edited)
// Original Code Provided by: Mat Buckland 2002 (fup@ai-junkie.com)
// Date : 18 March 2013
// --------------------------------------------------------------
#ifndef LOCATIONMACHINE_H
#define LOCATIONMACHINE_H

#define DEBUG_SECTION

#include <string>
#include "AbstractLocation.h"
#include "Telegram.h"
#include "UserInterface.h"
//#include "IPerson.h"

class IPerson;
class CLocation;

class CLocationMachine
{
public:
	CLocationMachine(IPerson* owner);
	virtual ~CLocationMachine();

	void SetCurrentLocation(CLocation* s);
	void SetPreviousLocation(CLocation* s);
  
	//call this to update the location machine
	void  Update() const;

	bool  HandleMessage(const Telegram& msg) const;

	//change to a new location
	void  ChangeLocation(CLocation* pNewLocation);

	//returns true if the current location's type is equal to the type of the
	//class passed as a parameter. 
	bool  isInLocation(const CLocation& loc) const;

	CLocation* CurrentLocation()  const;
	CLocation* PreviousLocation() const;

	//only ever used during debugging to grab the name of the current location
	std::string GetNameOfCurrentLocation() const;

	// Check to see if a location was visited
	bool LocationVisitedAlready(CLocation*) const;

private:
	// A map of all locations that have been visited so far
	map<CLocation*, bool> m_mLocationsVisited;

	//a pointer to the agent that owns this instance
	IPerson* m_pOwner;

	//the current location of the entity
	CLocation* m_pCurrentLocation;

	//a record of the location the entity came from
	CLocation* m_pPreviousLocation;
};

#endif